﻿using DocProcessingWorkflow.Helpers;
using FluentAssertions;
using NUnit.Framework;

namespace WebTests.Helpers
{
  [Category("Unit")]
  [TestFixture]
  public class SearchCriteriaHelperTests
  {
    [Test]
    public void GetSearchCriteria_WhenCalledWithoutDocumentSearchPart_ReturnsCorrectResult()
    {
      //Arrange

      const string searchCriteria = " act";

      //Act

      var result = SearchCriteriaHelper.GetSearchCriteria(searchCriteria);

      //Assert

      result.Item1.ShouldBeEquivalentTo("act","because this is the correct search criteria user supplied");
      result.Item2.Should().BeNull("because search criteria part does not contain part for document search");
    }

    [Test]
    public void GetSearchCriteria_WhenCalledWithDocumentSearchPart_ReturnsCorrectResult()
    {
      //Arrange
      
      const string searchCriteria = "act,jct";

      //Act

      var result = SearchCriteriaHelper.GetSearchCriteria(searchCriteria);

      //Assert

      result.Item1.Should().Be("act", "because this is the first part of search criteria user entered");
      result.Item2.Should().Be("jct", "because this is the second part of search criteria for document search");
    }

    [Test]
    public void GetSearchCriteria_WhenCalled_ResultStringIsTrimmedCorrectly()
    {
      //Arrange

      const string searchCriteria = " act , jct ";

      //Act

      var result = SearchCriteriaHelper.GetSearchCriteria(searchCriteria);

      //Assert

      result.Item1.Should().Be("act", "because this is the first part of search criteria user entered");
      result.Item2.Should().Be("jct", "because this is the second part of search criteria for document search");
    }


  }
}